JavaScript Array []
Example
// Create an Array
const cars = ["Saab", "Volvo", "BMW"];
Try it Yourself »
const cars = ["Saab", "Volvo", "BMW"];
More Examples Below !
Description
The [ ]
constructor creates a new array object.
Syntax
[iterable]
Parameters
Parameter
Description
iterable
Required.
An iterable object with values.
An iterable object with values.
Return Value
Type
Description
Array A new Array object.
Array Tutorials:
More Examples
Example
Create an empty array and add values:
// Create an Array
const cars = [];
// Add Values to the Set
cars.push("Saab");
cars.push("Volvo");
cars.push("BMW");
Try it Yourself »
const cars = [];
// Add Values to the Set
cars.push("Saab");
cars.push("Volvo");
cars.push("BMW");
Example
Create an array with the new Array() method:
// Create an Array
const cars = new Array(["Saab", "Volvo", "BMW"]);
Try it Yourself »
const cars = new Array(["Saab", "Volvo", "BMW"]);
Browser Support
the [] array constructor
is an ECMAScript1 (JavaScript 1997) feature.
It is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |